from math import *
class Player:
    def __init__(self):
		self.name="Abhishek"
		self.total_no_of_hunts= 0          	# A variable used to keep track of number of hunts
		
    def hunt_choices(self,round_number,current_food,current_reputation,m,player_reputations):
		hunt_decisions=[]                  	# List for storing hunting decisions.
		no_of_hunts_to_be_done= 0          	# Variable for storing the number of hunting decisions to be done.
											# m is used as a parameter for deciding the value of no. of times to become a hunter in hunts 
		if m<=(len(player_reputations)+1): 
			no_of_hunts_to_be_done=ceil(m/2)
		elif (m/(len(player_reputations)+1))>(len(player_reputations)/2):
			'''
											Dividing m by (len(player_reputations)+1) is eqivalent to dividing it by number of players for getting each players equal share
											of hunting to be carried in order to get reward.
			'''
			no_of_hunts_to_be_done=(ceil((len(player_reputations))/4))
		else:							   	
			no_of_hunts_to_be_done= (m/(len(player_reputations)+1))
		if round_number==1:                	# For round number 1 only 1 hunting decision is carried out
			for reputation in player_reputations:
				hunt_decisions.append('s')
			hunt_decisions[(len(hunt_decisions))/2]= 'h'
			self.total_no_of_hunts+= len(player_reputations)
			return hunt_decisions
		for reputation in player_reputations:
			if reputation== 0.00:           # For the player who always slacks
				hunt_decisions.append('s')  
			elif reputation == 1.00:        # For the player who always hunts
				hunt_decisions.append('s')  
			elif ((round((reputation*self.total_no_of_hunts)))-(self.total_no_of_hunts-(round((reputation*self.total_no_of_hunts)))))== -1:
				'''
											For the alternator. The alternator is identified by findinding out the difference between his decisions of to hunt or to slack.
											It can be -1 because of the odd number of hunts.
											Total no. of hunts= Hunting Decisions(H) + Slacking Decisions(S)
														Hence, H= Total no. of Hunts*Reputation
															   S= Total no. of hunts - H 
				'''
				hunt_decisions.append('s')
			elif ((round((reputation*self.total_no_of_hunts)))-(self.total_no_of_hunts-(round((reputation*self.total_no_of_hunts)))))== 1:
				'''
											For the alternator. The alternator is identified by findinding out the difference between his decisions of to hunt or to slack.
											It can be +1 because of the odd number of hunts.
											Total no. of hunts= Hunting Decisions(H) + Slacking Decisions(S)
														Hence, H= Total no. of Hunts*Reputation
															   S= Total no. of hunts - H 
				'''
				hunt_decisions.append('s')
			elif reputation==0.5:           #For the alternator
				hunt_decisions.append('s')
			elif reputation >0.67:          
				'''
											The player who has reputation of more than 0.67 is more tend to hunting and it is wise to hunt with the player who is also 
											hunting.
				'''
				if no_of_hunts_to_be_done > 0:
					hunt_decisions.append('h')
					no_of_hunts_to_be_done-=1
				else:
					hunt_decisions.append('s')
			elif 0.25<reputation<0.33:
				'''	
											Just an range in which it was worthy to go for hunting to cooperate and balance out.
				'''
				if no_of_hunts_to_be_done > 0:
					hunt_decisions.append('h')
					no_of_hunts_to_be_done-=1
				else:
					hunt_decisions.append('s')
			else:							# Slacking is a good option as it minimizes the loss if both slacks and maximizes the profit if opponenent hunts.
					hunt_decisions.append('s')
		self.total_no_of_hunts+= len(player_reputations)
		return hunt_decisions
		
        

    def hunt_outcomes(self, food_earnings):
        pass
        

    def round_end(self, award, m, number_hunters):
        pass
        